//
//  MainViewController.m
//  iOSBaseFramework
//
//  Created by user on 2020/7/3.
//  Copyright © 2020 com.taylor. All rights reserved.
//

#import "MainViewController.h"
#import "YDPartTimeJobViewController.h"
#import "YDMessageViewController.h"
#import "YDDevelopViewControler.h"
#import "YDPersonViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tabBar.barTintColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.tabBar.translucent = NO;
    
    [self addChildVCs];
}


-(void) dealloc {
    NSLog(@"%@ dealloc", NSStringFromClass([self class]));
}

-(void)addChildVCs {
    [self addChildVC:[YDPartTimeJobViewController new] title:@"兼职" imageName:@"discovery"];
    [self addChildVC:[YDMessageViewController new] title:@"消息" imageName:@"music"];
    [self addChildVC:[YDDevelopViewControler new] title:@"开发" imageName:@"friend"];
    [self addChildVC:[YDPersonViewController new] title:@"用户" imageName:@"account"];
}

-(void)addChildVC:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName {
    vc.tabBarItem.title = title;
    
    NSString *normalImageName = [NSString stringWithFormat:@"cm2_btm_icn_%@", imageName];
    NSString *selectImageName = [normalImageName stringByAppendingString:@"_ptr"];
    
    vc.tabBarItem.image = [UIImage imageNamed:normalImageName];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectImageName];
    
    vc.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -2);
    
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor grayColor]} forState:UIControlStateNormal];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateSelected];
    
    UINavigationController *nav = [UINavigationController rootVC:vc transitionScale:false];
    [self addChildViewController:nav];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
